package com.wang.test.demo.putong;

import com.wang.test.demo.entity.ListVO;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * @author wangzhenjun
 * @date 2022/3/3 17:24
 */
public class String1 {

    public static void main(String[] args) {
        String str6 = new String("学") + new String("Java");

        String str71 = new String("学Java");
        String str81 = new String("学Java");
        System.out.println(str71 == str81);
        StringBuilder stringBuilder = new StringBuilder().append("s");
        str71.intern();

        LocalDateTime dateTime = LocalDateTime.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
        String dateTimeStr = dateTime.format(dateTimeFormatter);

        System.out.println(dateTimeStr);
        LocalDateTime after = dateTime.plusMonths(1);

        String dateTimeStrAfter = after.format(dateTimeFormatter);

        System.out.println(dateTimeStrAfter);
        String str7 = new String("wang") + new String("zhen");
        String str8 = "wangzhen";
        System.out.println(str7.intern() == str8); // true
        System.out.println(str7 == str8); // false
        System.out.println(str8 == "wangzhen");

        List<String> stringList = new ArrayList<>();
        stringList.add("a");
        stringList.add("a1");
        stringList.add("a2");
        stringList.add("a4");
        stringList.add("a12");

        stringList.add("a23");stringList.add("a45");
        stringList.add("a18");
        stringList.add("9999");stringList.add("a21");
        stringList.add("===");
        if (stringList.size() <= 10) {
            System.out.println("============");
        }

        //List newList = stringList.subList(1,stringList.size());
        List<String> other = stringList.subList(10, stringList.size());
        //List<String> top10 = stringList.subList(0, 10);

        System.out.println(com.alibaba.fastjson.JSON.toJSONString(stringList));
        System.out.println(com.alibaba.fastjson.JSON.toJSONString(other));
        //System.out.println(com.alibaba.fastjson.JSON.toJSONString(top10));

        List<Integer> list = new ArrayList<>();
        list.add(2);
        list.removeIf(item -> (item + "").equals("2"));
        System.out.println(com.alibaba.fastjson.JSON.toJSONString(list));

        LocalDate now = LocalDate.now();
        LocalDate localDate = now.minusMonths(2);
        String s = String.valueOf(now);
        System.out.println(s);
        long between = ChronoUnit.DAYS.between(localDate, now);
        System.out.println(between);
        System.out.println(localDate);
        System.out.println(now);

        List<Integer> list1 = Arrays.asList(1,2,3,4,5);
        List<Integer> list2 =Arrays.asList(1,2,3,4,5);
        List<Integer> list3 =Arrays.asList(1,2,3,4,5);

        ListVO listVO = new ListVO();
        listVO.setList(list1);
        ListVO listVO1 = new ListVO();
        listVO1.setList(list2);
        ListVO listVO2 = new ListVO();
        listVO2.setList(list3);
        List<ListVO> listVOS = new ArrayList<>();
        listVOS.add(listVO);
        listVOS.add(listVO1);
        listVOS.add(listVO2);
        //int maxSize = list1.size()>list2.size()?list1.size():list2.size();
        List<Integer> result = IntStream.range(0, list1.size())
                .map(i -> list1.get(i)+list2.get(i)+list3.get(i)
                ).boxed().collect(Collectors.toList());

        System.out.println(result);

        ListVO firstEle = listVOS.get(0);
        Integer[] x =new Integer[firstEle.getList().size()];
        List<Integer> newList = new ArrayList<>();
        for(int i = 0; i< firstEle.getList().size(); i++){
            x[i]=0;
            for (int j = 0; j < listVOS.size(); j++) {
                x[i] += listVOS.get(j).getList().get(i);
            }
        }
        System.out.println(com.alibaba.fastjson.JSON.toJSONString(x));
    }
}
